docs: document LLM event freshness behavior#406
Conversation
Signed-off-by: Will Killian <wkillian@nvidia.com>
WalkthroughDocumentation updates clarify LLM annotation freshness, sanitized request projections, codec behavior, provider execution input, and CLI compaction hook coverage. ChangesEvent Semantics Documentation
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/about-nemo-relay/concepts/events.mdx`:
- Around line 83-96: Restructure the dense paragraph about LLM start annotations
into a short bulleted list, with one item each for freshness and retention,
nested-agent independence, non-agent scope inheritance, codec projection and
fallback, concurrent-start behavior, and event independence. Preserve all
existing semantics and details while making each concept independently
scannable.
In `@docs/instrument-applications/instrument-llm-call.mdx`:
- Around line 241-245: Update the stale-session annotation description near
“sanitize-request guardrails” to match events.mdx and atof.mdx: state that stale
annotations retain system instructions, the latest user message, and subsequent
assistant/tool messages, rather than only the current user turn. Preserve the
distinction that fresh sessions retain complete history and that the request
codec applies the same projection to emitted event input.
In `@skills/nemo-relay-export-atif-trajectories/SKILL.md`:
- Around line 26-30: Clarify the documentation near the annotation and
projection behavior to distinguish retained annotation history from exported
ATIF content: annotations preserve complete history when available, while the
ATIF adapter’s user-step projection, implemented in the relevant ATIF conversion
logic, includes only the latest User message (or the documented fallback
projection). State that request codecs affect event input projection without
changing provider execution.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: f3ad473f-36f3-4d72-8084-263dc9b2c221
📒 Files selected for processing (9)
docs/about-nemo-relay/concepts/events.mdxdocs/configure-plugins/observability/atof.mdxdocs/instrument-applications/instrument-llm-call.mdxdocs/nemo-relay-cli/basic-usage.mdxdocs/nemo-relay-cli/claude-code.mdxdocs/nemo-relay-cli/codex.mdxskills/nemo-relay-export-atif-trajectories/SKILL.mdskills/nemo-relay-export-openinference/SKILL.mdskills/nemo-relay-setup-observability/SKILL.md
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
- GitHub Check: CodeRabbit
🧰 Additional context used
📓 Path-based instructions (14)
**/*.{md,rst,html,txt}
📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-brand-terminology.md)
**/*.{md,rst,html,txt}: Always spellNVIDIAin all caps. Do not useNvidia,nvidia,nVidia,nVIDIA, orNV.
Usean NVIDIAbefore a noun because the name starts with an 'en' sound.
Do not add a registered trademark symbol afterNVIDIAwhen referring to the company.
Use trademark symbols with product names only when the document type or legal guidance requires them.
Verify official capitalization, spacing, and hyphenation for product names.
Precede NVIDIA product names withNVIDIAon first mention when it is natural and accurate.
Do not rewrite product names for grammar or title-case rules.
Preserve third-party product names according to the owner's spelling.
Include the company name and full model qualifier on first use when it helps identify the model.
Preserve the official capitalization and punctuation of model names.
Use shorter family names only after the full name is established.
Spell out a term on first use and put the acronym in parentheses unless the acronym is widely understood by the intended audience.
Use the acronym on later mentions after it has been defined.
For long documents, reintroduce the full term if readers might lose context.
Form plurals of acronyms withs, not an apostrophe, such asGPUs.
In headings, common acronyms can remain abbreviated. Spell out the term in the first or second sentence of the body.
Common terms such asCPU,GPU,PC,API, andUIusually do not need to be spelled out for developer audiences.
Files:
skills/nemo-relay-setup-observability/SKILL.mdskills/nemo-relay-export-openinference/SKILL.mdskills/nemo-relay-export-atif-trajectories/SKILL.md
**/*.{md,rst,html}
📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-brand-terminology.md)
Link the first mention of a product name when the destination helps the reader.
Files:
skills/nemo-relay-setup-observability/SKILL.mdskills/nemo-relay-export-openinference/SKILL.mdskills/nemo-relay-export-atif-trajectories/SKILL.md
**/*.{md,rst,txt}
📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-guide.md)
Spell
NVIDIAin all caps. Do not useNvidia,nvidia, orNV.
Files:
skills/nemo-relay-setup-observability/SKILL.mdskills/nemo-relay-export-openinference/SKILL.mdskills/nemo-relay-export-atif-trajectories/SKILL.md
**/*.{md,rst}
📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-guide.md)
**/*.{md,rst}: Format commands, code elements, expressions, package names, file names, and paths as inline code.
Use descriptive link text. Avoid raw URLs and weak anchors such as "here" or "read more."
Use title case consistently for technical documentation headings.
Introduce code blocks, lists, tables, and images with complete sentences.
Write procedures as imperative steps. Keep steps parallel and split long procedures into smaller tasks.
Prefer active voice, present tense, short sentences, contractions, and plain English.
Usecanfor possibility and reservemayfor permission.
Useafterfor temporal relationships instead ofonce.
Preferrefer tooverseewhen the wording points readers to another resource.
Avoid culture-specific idioms, unnecessary Latinisms, jokes, and marketing exaggeration in technical docs.
Spell out months in body text, avoid ordinal dates, and use clear time zones.
Spell out whole numbers from zero through nine unless they are technical values, parameters, versions, or UI values.
Use numerals for 10 or greater and include commas in thousands.
Do not add trademark symbols to learning-oriented docs unless the source, platform, or legal guidance explicitly requires them.
Files:
skills/nemo-relay-setup-observability/SKILL.mdskills/nemo-relay-export-openinference/SKILL.mdskills/nemo-relay-export-atif-trajectories/SKILL.md
**/*.md
📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-technical-docs.md)
**/*.md: Use title case consistently in technical documentation headings
Avoid quotation marks, ampersands, and exclamation marks in headings
Keep product, event, research, and whitepaper names in their official title case
Use title case for table headers
Do not force social-media sentence case into technical docs
Format code elements, commands, parameters, package names, and expressions in monospace
Format directories, file names, and paths in monospace using backticks
Use angle brackets inside monospace for variables inside paths, such as/home/<username>/.login
Format error messages and strings in quotation marks, keeping literal code strings in code formatting when clearer
Format UI buttons, menus, fields, and labels in bold
Use angle brackets between UI labels for menu paths, such as File > Save As
Use italics for new terms on first use, sparingly and only when introducing the term
Use italics for publication titles
Format keyboard shortcuts in plain text, such as Press Ctrl+Alt+Delete
Use owner/repo link text for GitHub repositories, preferring[NVIDIA/NeMo](link)over prose references like 'the GitHub repo'
Introduce every code block with a complete sentence
Do not make a code block complete the grammar of the previous sentence
Do not continue a sentence after a code block
Use syntax highlighting when the format supports it for code blocks
Avoid the word 'snippet' unless the surrounding docs already use it as a term of art
Keep inline method, function, and class references consistent with nearby docs, omitting empty parentheses for prose readability when no call is shown
Use descriptive anchor text that matches the destination title when possible for links
Avoid raw URLs in running text
Avoid generic anchor text such as 'here,' 'this page,' and 'read more'
Include acronyms in link text when a linked term includes an acronym
Do not link long sentences or multiple sentences
Avoid links that pull readers away from a procedure unless the link is a p...
Files:
skills/nemo-relay-setup-observability/SKILL.mdskills/nemo-relay-export-openinference/SKILL.mdskills/nemo-relay-export-atif-trajectories/SKILL.md
**/SKILL.md
📄 CodeRabbit inference engine (AGENTS.md)
SKILL.mdfiles are skill entrypoints and must start with YAML frontmatter containing at leastnameanddescription.
Files:
skills/nemo-relay-setup-observability/SKILL.mdskills/nemo-relay-export-openinference/SKILL.mdskills/nemo-relay-export-atif-trajectories/SKILL.md
⚙️ CodeRabbit configuration file
**/SKILL.md: Do not flag SKILL.md files for missing SPDX headers. Skill entrypoints intentionally start with YAML frontmatter instead.
Verify that every SKILL.md keeps valid YAML frontmatter with at least name and description fields before the Markdown body.
Files:
skills/nemo-relay-setup-observability/SKILL.mdskills/nemo-relay-export-openinference/SKILL.mdskills/nemo-relay-export-atif-trajectories/SKILL.md
**/*.{md,mdx}
📄 CodeRabbit inference engine (AGENTS.md)
Update
README.md,fern/, package READMEs, and binding-support notes when public behavior, package names, examples, or supported bindings change.
**/*.{md,mdx}: Prefer the documented public API, not internal shortcuts
Keep package names, repo references, and build commands current
Keep release-process and release-notes guidance in repo-maintainer docs such asRELEASING.md, not as user-facing docs pages orCHANGELOG.md
Keep stable user-facing wrappers atscripts/root in docs and examples; only point at namespaced helper paths when documenting internal maintenance work
When detailed dynamic plugin guides exist, keep Rust native plugin examples, Python worker plugin examples, andgrpc-v1protocol details on separate pagesIf links in documentation change, run
just docs-linkcheck.
Files:
skills/nemo-relay-setup-observability/SKILL.mddocs/configure-plugins/observability/atof.mdxskills/nemo-relay-export-openinference/SKILL.mddocs/nemo-relay-cli/basic-usage.mdxdocs/nemo-relay-cli/claude-code.mdxskills/nemo-relay-export-atif-trajectories/SKILL.mddocs/instrument-applications/instrument-llm-call.mdxdocs/about-nemo-relay/concepts/events.mdxdocs/nemo-relay-cli/codex.mdx
**/*.{md,markdown,mdx}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Add the SPDX license header to all Markdown/MDX documentation files using the HTML comment block form.
Files:
skills/nemo-relay-setup-observability/SKILL.mddocs/configure-plugins/observability/atof.mdxskills/nemo-relay-export-openinference/SKILL.mddocs/nemo-relay-cli/basic-usage.mdxdocs/nemo-relay-cli/claude-code.mdxskills/nemo-relay-export-atif-trajectories/SKILL.mddocs/instrument-applications/instrument-llm-call.mdxdocs/about-nemo-relay/concepts/events.mdxdocs/nemo-relay-cli/codex.mdx
**/*
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
**/*: Format changed files with the language-native formatter before the final lint/test pass.
If dynamic plugin behavior changed, usemaintain-dynamic-pluginsand include the native SDK, worker protocol, Python SDK, docs, packaging, and Codecov surfaces in the validation plan.
If code changes alter APIs, bindings, commands, paths, packaging behavior, observability/adaptive semantics, or documented best practices, update any dependent maintainer or consumer skills in the same branch.
During iteration, preferuv run pre-commit run --files <changed files...>.
Before review or handoff, runuv run pre-commit run --all-files.
Files:
skills/nemo-relay-setup-observability/SKILL.mddocs/configure-plugins/observability/atof.mdxskills/nemo-relay-export-openinference/SKILL.mddocs/nemo-relay-cli/basic-usage.mdxdocs/nemo-relay-cli/claude-code.mdxskills/nemo-relay-export-atif-trajectories/SKILL.mddocs/instrument-applications/instrument-llm-call.mdxdocs/about-nemo-relay/concepts/events.mdxdocs/nemo-relay-cli/codex.mdx
**
⚙️ CodeRabbit configuration file
**:AGENTS.md
This file provides guidance to agents, including Claude Code and OpenAI Codex, when working in this repository.
Project Overview
NeMo Relay is a multi-language agent runtime framework for execution scopes, lifecycle events, middleware, plugins, and observability around tool and LLM calls. The core runtime is Rust. Primary supported bindings are Rust, Python, and Node.js. Go and the raw C FFI are experimental and source-first.
The shared runtime model is:
- Scope stacks decide where work belongs and which scope-local behavior is visible.
- Middleware registries decide what guardrails and intercepts run around managed calls.
- Plugins install reusable runtime behavior from configuration.
- Events record runtime behavior in ATOF form.
- Subscribers and exporters consume events in-process or export them to ATIF, OpenTelemetry, OpenInference, or other backends.
Repository Structure
The repository layout separates the Rust runtime, language bindings,
documentation, integrations, and agent-facing skills.crates/ core/ # Rust core runtime crate, published as nemo-relay adaptive/ # Adaptive runtime primitives and plugin components python/ # PyO3 native extension for the Python package ffi/ # Raw C ABI layer used by downstream bindings such as Go node/ # NAPI Node.js binding and JavaScript/TypeScript entry points python/ nemo_relay/ # Python wrapper package: scopes, tools, LLM, middleware, typed helpers, plugins, adaptive helpers tests/ # Python tests go/ nemo_relay/ # Experimental Go CGo binding and tests fern/ # Fern documentation site scripts/ # Stable wrappers and helper scripts; build/test/docs entry points live in justfile skills/ # Published Codex/agent skills for NeMo Relay usage patternsPrerequisites
Insta...
Files:
skills/nemo-relay-setup-observability/SKILL.mddocs/configure-plugins/observability/atof.mdxskills/nemo-relay-export-openinference/SKILL.mddocs/nemo-relay-cli/basic-usage.mdxdocs/nemo-relay-cli/claude-code.mdxskills/nemo-relay-export-atif-trajectories/SKILL.mddocs/instrument-applications/instrument-llm-call.mdxdocs/about-nemo-relay/concepts/events.mdxdocs/nemo-relay-cli/codex.mdx
**/*.mdx
📄 CodeRabbit inference engine (.agents/skills/review-doc-style/SKILL.md)
MDX top-of-file SPDX comments must use {/* ... */} delimiters instead of HTML comment delimiters (Must-Fix)
In MDX files, top-of-file comments must use JSX comment delimiters (
{/*to open and*/}to close); do not use HTML comments for MDX SPDX headers
Files:
docs/configure-plugins/observability/atof.mdxdocs/nemo-relay-cli/basic-usage.mdxdocs/nemo-relay-cli/claude-code.mdxdocs/instrument-applications/instrument-llm-call.mdxdocs/about-nemo-relay/concepts/events.mdxdocs/nemo-relay-cli/codex.mdx
{docs,examples}/**/*
📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)
Update docs and examples.
Files:
docs/configure-plugins/observability/atof.mdxdocs/nemo-relay-cli/basic-usage.mdxdocs/nemo-relay-cli/claude-code.mdxdocs/instrument-applications/instrument-llm-call.mdxdocs/about-nemo-relay/concepts/events.mdxdocs/nemo-relay-cli/codex.mdx
docs/**/*
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
If documentation examples or commands under
docs/change, run the targeted docs checks appropriate to the change.
Files:
docs/configure-plugins/observability/atof.mdxdocs/nemo-relay-cli/basic-usage.mdxdocs/nemo-relay-cli/claude-code.mdxdocs/instrument-applications/instrument-llm-call.mdxdocs/about-nemo-relay/concepts/events.mdxdocs/nemo-relay-cli/codex.mdx
{docs/**,README.md,CONTRIBUTING.md,RELEASING.md,SECURITY.md}
⚙️ CodeRabbit configuration file
{docs/**,README.md,CONTRIBUTING.md,RELEASING.md,SECURITY.md}: Review documentation for technical accuracy against the current API, command correctness, and consistency across language bindings.
Flag stale examples, missing SPDX headers where required, and instructions that no longer match CI or pre-commit behavior.
Files:
docs/configure-plugins/observability/atof.mdxdocs/nemo-relay-cli/basic-usage.mdxdocs/nemo-relay-cli/claude-code.mdxdocs/instrument-applications/instrument-llm-call.mdxdocs/about-nemo-relay/concepts/events.mdxdocs/nemo-relay-cli/codex.mdx
🔇 Additional comments (9)
docs/about-nemo-relay/concepts/events.mdx (2)
111-111: LGTM!
93-95: 🎯 Functional CorrectnessClarify the concurrent-start guarantee
docs/about-nemo-relay/concepts/events.mdx:93-95— the implementation path here shows per-call event construction, but not the mechanism that makes “exactly one consumes a fresh state” hold under concurrent starts. Soften the wording or point to the specific ownership/synchronization path.docs/instrument-applications/instrument-llm-call.mdx (1)
246-248: LGTM!docs/configure-plugins/observability/atof.mdx (1)
104-108: LGTM!docs/nemo-relay-cli/claude-code.mdx (1)
125-129: LGTM!docs/nemo-relay-cli/codex.mdx (1)
184-185: LGTM!skills/nemo-relay-export-openinference/SKILL.md (1)
32-36: LGTM!skills/nemo-relay-setup-observability/SKILL.md (1)
41-45: LGTM!docs/nemo-relay-cli/basic-usage.mdx (1)
309-310: LGTM!
| LLM start annotations retain complete sanitized request history while their | ||
| owning agent session is fresh: initially and after a compaction mark. Once the | ||
| agent begins a turn, later annotations retain system instructions, the latest | ||
| user message, and every following assistant or tool message. Nested agents | ||
| track freshness independently. The implicit root is an agent freshness owner. | ||
| Non-agent scopes, including function and custom scopes used to model requests, | ||
| inherit their nearest agent's freshness instead of starting a new budget. When | ||
| a request codec is active, it projects the event's provider-shaped input to the | ||
| same history. If that event-only encode fails, Relay retains the complete event | ||
| input and annotation and continues the provider call. The request used for | ||
| provider execution remains unchanged. Concurrent starts have no guaranteed | ||
| emission order, but exactly one consumes a fresh state. Events are independent | ||
| observations rather than a replayable history stream. | ||
|
|
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
Dense paragraph mixes six distinct concepts.
This paragraph packs freshness definition, turn-based retention, nested-agent independence, non-agent scope inheritance, codec projection/fallback, and concurrent-start semantics into one block. Splitting into a short bulleted list (one idea per item) would make this easier to scan.
📝 Suggested restructure
-LLM start annotations retain complete sanitized request history while their
-owning agent session is fresh: initially and after a compaction mark. Once the
-agent begins a turn, later annotations retain system instructions, the latest
-user message, and every following assistant or tool message. Nested agents
-track freshness independently. The implicit root is an agent freshness owner.
-Non-agent scopes, including function and custom scopes used to model requests,
-inherit their nearest agent's freshness instead of starting a new budget. When
-a request codec is active, it projects the event's provider-shaped input to the
-same history. If that event-only encode fails, Relay retains the complete event
-input and annotation and continues the provider call. The request used for
-provider execution remains unchanged. Concurrent starts have no guaranteed
-emission order, but exactly one consumes a fresh state. Events are independent
-observations rather than a replayable history stream.
+LLM start annotations retain complete sanitized request history while their
+owning agent session is fresh: initially and after a compaction mark. Once the
+agent begins a turn, later annotations retain system instructions, the latest
+user message, and every following assistant or tool message.
+
+- Nested agents track freshness independently, and the implicit root is an
+ agent freshness owner.
+- Non-agent scopes, including function and custom scopes used to model
+ requests, inherit their nearest agent's freshness instead of starting a new
+ budget.
+- When a request codec is active, it projects the event's provider-shaped
+ input to the same history. If that event-only encode fails, Relay retains
+ the complete event input and annotation and continues the provider call.
+ The request used for provider execution remains unchanged.
+- Concurrent starts have no guaranteed emission order, but exactly one
+ consumes a fresh state. Events are independent observations rather than a
+ replayable history stream.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| LLM start annotations retain complete sanitized request history while their | |
| owning agent session is fresh: initially and after a compaction mark. Once the | |
| agent begins a turn, later annotations retain system instructions, the latest | |
| user message, and every following assistant or tool message. Nested agents | |
| track freshness independently. The implicit root is an agent freshness owner. | |
| Non-agent scopes, including function and custom scopes used to model requests, | |
| inherit their nearest agent's freshness instead of starting a new budget. When | |
| a request codec is active, it projects the event's provider-shaped input to the | |
| same history. If that event-only encode fails, Relay retains the complete event | |
| input and annotation and continues the provider call. The request used for | |
| provider execution remains unchanged. Concurrent starts have no guaranteed | |
| emission order, but exactly one consumes a fresh state. Events are independent | |
| observations rather than a replayable history stream. | |
| LLM start annotations retain complete sanitized request history while their | |
| owning agent session is fresh: initially and after a compaction mark. Once the | |
| agent begins a turn, later annotations retain system instructions, the latest | |
| user message, and every following assistant or tool message. | |
| - Nested agents track freshness independently, and the implicit root is an | |
| agent freshness owner. | |
| - Non-agent scopes, including function and custom scopes used to model | |
| requests, inherit their nearest agent's freshness instead of starting a new | |
| budget. | |
| - When a request codec is active, it projects the event's provider-shaped | |
| input to the same history. If that event-only encode fails, Relay retains | |
| the complete event input and annotation and continues the provider call. | |
| The request used for provider execution remains unchanged. | |
| - Concurrent starts have no guaranteed emission order, but exactly one | |
| consumes a fresh state. Events are independent observations rather than a | |
| replayable history stream. |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/about-nemo-relay/concepts/events.mdx` around lines 83 - 96, Restructure
the dense paragraph about LLM start annotations into a short bulleted list, with
one item each for freshness and retention, nested-agent independence, non-agent
scope inheritance, codec projection and fallback, concurrent-start behavior, and
event independence. Preserve all existing semantics and details while making
each concept independently scannable.
| sanitize-request guardrails. Annotations retain complete history while their | ||
| agent session is fresh (initially and after compaction); later events contain | ||
| the current user turn. With a request codec, the emitted event input uses the | ||
| same projection. This event-only projection does not change the request used | ||
| for provider execution. |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Stale-session retention description is inconsistent with events.mdx and atof.mdx.
This says stale annotations "contain the current user turn," but events.mdx (lines 85-86) and atof.mdx (lines 105-107) both specify that stale annotations retain system instructions, the latest user message, and subsequent assistant/tool messages. As written here, a reader could conclude the system prompt is dropped once a turn begins.
📝 Suggested wording fix
- sanitize-request guardrails. Annotations retain complete history while their
- agent session is fresh (initially and after compaction); later events contain
- the current user turn. With a request codec, the emitted event input uses the
+ sanitize-request guardrails. Annotations retain complete history while their
+ agent session is fresh (initially and after compaction); later events retain
+ system instructions, the latest user message, and subsequent assistant or
+ tool messages. With a request codec, the emitted event input uses the📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| sanitize-request guardrails. Annotations retain complete history while their | |
| agent session is fresh (initially and after compaction); later events contain | |
| the current user turn. With a request codec, the emitted event input uses the | |
| same projection. This event-only projection does not change the request used | |
| for provider execution. | |
| sanitize-request guardrails. Annotations retain complete history while their | |
| agent session is fresh (initially and after compaction); later events retain | |
| system instructions, the latest user message, and subsequent assistant or | |
| tool messages. With a request codec, the emitted event input uses the | |
| same projection. This event-only projection does not change the request used | |
| for provider execution. |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/instrument-applications/instrument-llm-call.mdx` around lines 241 - 245,
Update the stale-session annotation description near “sanitize-request
guardrails” to match events.mdx and atof.mdx: state that stale annotations
retain system instructions, the latest user message, and subsequent
assistant/tool messages, rather than only the current user turn. Preserve the
distinction that fresh sessions retain complete history and that the request
codec applies the same projection to emitted event input.
| request annotation when possible. Annotations retain complete history while | ||
| their agent session is fresh (initially and after compaction); otherwise, the | ||
| projection retains system instructions, the latest user message, and following | ||
| assistant or tool messages. With a request codec, the event input uses the same | ||
| projection; provider execution remains unchanged. |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Clarify annotation history versus exported ATIF content.
The ATIF adapter in crates/core/src/observability/atif.rs:1040-1105 currently projects only the latest User message into the ATIF message; it does not emit the complete annotated history. Clarify that full history is retained by the annotation, while the ATIF user-step projection is narrower.
Suggested wording
- request annotation when possible. Annotations retain complete history while
+ request annotation when possible. The annotation retains complete history while
their agent session is fresh (initially and after compaction); otherwise, the
- projection retains system instructions, the latest user message, and following
- assistant or tool messages. With a request codec, the event input uses the same
- projection; provider execution remains unchanged.
+ annotation projection retains system instructions, the latest user message, and
+ following assistant or tool messages. The ATIF user-step projection extracts
+ the latest user message. With a request codec, the event input uses the same
+ annotation projection; provider execution remains unchanged.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@skills/nemo-relay-export-atif-trajectories/SKILL.md` around lines 26 - 30,
Clarify the documentation near the annotation and projection behavior to
distinguish retained annotation history from exported ATIF content: annotations
preserve complete history when available, while the ATIF adapter’s user-step
projection, implemented in the relevant ATIF conversion logic, includes only the
latest User message (or the documented fallback projection). State that request
codecs affect event input projection without changing provider execution.
#### Overview > [!WARNING] > **BREAKING CHANGE (Behavioral):** LLM start request event inputs and annotations can omit earlier turns after the owning agent's freshness has been consumed. The request used for provider execution remains unchanged. Implement RELAY-445 with per-agent freshness. A new agent session, and the first LLM start after compaction, retains the complete sanitized request history. Later starts cull the annotation and codec-backed event input to the current user turn. - [x] I confirm this contribution is my own work, or I have the right to submit it under this project's license. - [x] I searched existing issues and open pull requests, and this does not duplicate existing work. #### Details - Track freshness for the implicit root and nested agent scopes independently, and remove explicit-agent state when its scope closes. Non-agent scopes inherit their nearest agent's freshness instead of creating a separate budget. - Atomically consume freshness at LLM start. Concurrent starts need not have a stable emission order, but exactly one consumes a fresh state. - Mark the owning agent fresh on canonical `compaction` events. Repeated marks are idempotent, and both `PreCompact` and `PostCompact` normalize to the shared canonical event name. - For stale agents, retain system instructions, the latest user message, and every following assistant or tool message. Handle empty, instruction-only, and no-user histories without cloning an annotation when projection is a no-op. - When a request codec is active, encode the projected annotation into the event-only `LlmRequest` so `event.input` and `category_profile.annotated_request` contain the same bounded history. If that event-only encode fails, emit a diagnostic, preserve the complete event input and annotation, and continue the provider call. - Leave response payloads, middleware/provider requests, caller-visible values, and existing public API signatures unchanged. This implementation has no history baselines, ordering queues, or response projection. - Keep ordinary mark events on the scope-stack read-lock path; acquire the write lock only for canonical compaction marks. - Add real-codec coverage for managed and streaming calls, including fail-open encode errors; projection edge cases and no-op allocation behavior; implicit-root and nested-agent inheritance; concurrent starts; and repeated compaction marks. - Move documentation and consumer-skill updates to the documentation-only follow-up PR #406. Validation: - `cargo fmt --all` - `just test-rust` — 833 core unit tests plus integration tests passed - `cargo clippy --workspace --all-targets -- -D warnings` - `just test-python` — 511 passed - `just test-node` — 254 passed - `just test-go` - `uv run pre-commit run --all-files` #### Where should the reviewer start? Start with `crates/core/src/api/runtime/scope_stack.rs` for the root/nested-agent freshness ownership, `crates/core/src/api/llm.rs` for fail-open event-only request projection, and `crates/core/tests/unit/llm_api_tests.rs` for the behavioral contract. #### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to) - Fixes: RELAY-445 Authors: - Will Killian (https://github.com/willkill07) Approvers: - Maryam Najafian (https://github.com/mnajafian-nv) URL: #398
Overview
Document the LLM event-history freshness and compaction behavior implemented by #398. This documentation-only follow-up should merge after #398 so the runtime review can remain focused on implementation and tests.
Details
compactionmarks andPreCompact/PostCompactnormalization in the CLI guides.Validation:
just docsuv run pre-commit run --files <nine changed documentation and skill files>git diff --checkWhere should the reviewer start?
Start with
docs/about-nemo-relay/concepts/events.mdxfor the canonical event contract andskills/nemo-relay-export-atif-trajectories/SKILL.mdfor the retained stale-history shape.Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
Summary by CodeRabbit
PostCompactand canonical compaction marks.